package com.tanhua.dubbo.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.logging.Logger;

@Component
public class MyMetaObjectHandler implements MetaObjectHandler {



    //insert操作时要填充的字段
    @Override
    public void insertFill(MetaObject metaObject) {

        //根据属性名字设置要填充的值
        this.setFieldValByName("created",new Date(),metaObject);
        this.setFieldValByName("updated",new Date(),metaObject);
    }

    //update操作时要填充的字段
    @Override
    public void updateFill(MetaObject metaObject) {

        this.setFieldValByName("updated",new Date(),metaObject);
    }
}